package com.hnust.dao;

import com.hnust.domain.AlternativeAnswer;
import com.hnust.domain.Question;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import javax.xml.ws.soap.Addressing;
import java.util.List;

@Mapper
@Repository
public interface QuestionRecordDao {
   //添加答题记录
    @Insert("insert into question_record(que_rec_id,`right`,time,mod_time,cre_time,stu_id,que_id,que_rec_type_id) values (#{queRecId},#{right},#{time},#{modTime},#{creTime},#{studentId},#{questionId},#{queRecTypeId} )")
    @ResultType(Integer.class)
    Integer addRecord(String queRecId, Integer right, String time, String modTime, String creTime, String studentId, String questionId, String queRecTypeId);

    //返回答题总数
    @Select("select count(*) from question_record where stu_id=#{stu_id} and que_rec_type_id=2")
    @ResultType(Integer.class)
    Integer countQuestionRecord(String stu_id);

    //返回答题正确数
    @Select("select count(*) from question_record where stu_id=#{stu_id} and `right`=1 and que_rec_type_id=2")
    @ResultType(Integer.class)
    Integer countRightQuestionRecord(String stu_id);

}
